<?php

/**
 * mediaPhoto actions.
 *
 * @package    cpfaizenay
 * @subpackage mediaPhoto
 * @author     Manu
 * @version    1.0
 */
class mediaPhotoActions extends sfActions
{
 /**
  * Executes index action
  *
  * @param sfRequest $request A request object
  */
  public function executeIndex(sfWebRequest $request) {
      $this->albumsPhotos = Doctrine::getTable('Category')->getPhotosCategories(null, 'published')->fetchArray();
      $this->lastPhotosByAlbum = Doctrine::getTable('sfAssetMedia')->getLastPhotosByAlbum()->fetchArray();

      isicsBreadcrumbs::getInstance()->addItem('Galerie photos', '#');

      $response = $this->getResponse();
      Utils::setSlogTitle('Galerie photos du club', $response);
  }

  public function executeShowGallery(sfWebRequest $request) {
      $this->slug_category = $request->getParameter('title_slug');

      $this->photos_list = Doctrine::getTable('sfAssetMedia')->getPhotos($this->slug_category)->fetchArray();
      $this->forward404Unless($this->photos_list);

      $this->slug_filename = $request->getParameter('filename_slug');
      if(empty($this->slug_filename)){
          $this->slug_filename = $this->photos_list[0]['sfAsset'][ 'slug' ];
      }

      $this->current_photo = Doctrine::getTable('sfAssetMedia')->getPhoto($this->slug_filename)->fetchOne();
      $this->forward404Unless($this->current_photo);

      isicsBreadcrumbs::getInstance()->addItem('Galerie photos', '@gallery_photos');
      isicsBreadcrumbs::getInstance()->addItem($this->photos_list[0][ 'Category' ][ 'title' ], '#');

      $response = $this->getResponse();
      Utils::setSlogTitle("Galerie photos " . $this->current_photo[ 'Category' ][ 'title' ], $response);

      $response->addMeta('og:image', sfConfig::get('app_homePage_uri') . "/" . $this->current_photo['sfAsset'][ 'Folder' ][ 'relative_path' ] . "/thumbnail/small_" . $this->current_photo['sfAsset'][ 'filename' ]);

  }

}